package com.ruoyi.system.api.impl;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.account.service.ISxoSafetyLogService;
import com.ruoyi.account.util.PaPayUtil;
import com.ruoyi.system.api.BaseClient;
import com.ruoyi.system.config.TaskExecutePoolConfig;


/**
 * 查询银行子账户余额-KFEJZB6010
 */
public class CustAcctIdBalanceQueryApi extends BaseClient {

    private final ISxoSafetyLogService sxoSafetyLogService;
    private final TaskExecutePoolConfig taskExecutePoolConfig;

    public CustAcctIdBalanceQueryApi(ISxoSafetyLogService sxoSafetyLogService, TaskExecutePoolConfig taskExecutePoolConfig){
        this.sxoSafetyLogService=sxoSafetyLogService;
        this.taskExecutePoolConfig=taskExecutePoolConfig;
    }

    @Override
    public String getApiUrl() {
        return PaPayUtil.CUST_ACCT_ID_BALANCE_QUERY;
    }

    @Override
    public void saveResult(String logId, String result) {
        taskExecutePoolConfig.getAsyncExecutor().execute(() -> {
            sxoSafetyLogService.updateSafetyLog(logId, result);
        });
    }

    @Override
    public String saveLog(JSONObject params) {
        String busId = params.getString("MemberAcctNo");
        return sxoSafetyLogService.saveSafetyLog("", busId, PaPayUtil.CUST_ACCT_ID_BALANCE_QUERY, params.toJSONString());
    }

}
